// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const rp = require('request-promise')

let URL = 'https://apis.map.qq.com/ws/geocoder/v1/?key=SZABZ-NFSRK-2I4JL-AUING-BAMA3-WSFP5&address='

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  URL += '衡水'
  URL += event.address
   // 2. 当前需要插入到云数据库数据
  const address = await rp(URL).then((res) => {
     //console.log(URL,res)
    return res
  })

  return URL
}